namespace WanFang.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class add_ceshi : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.JianCe",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Material_Id = c.Int(nullable: false),
                        JianCeDate = c.DateTime(nullable: false),
                        Supplier = c.String(),
                        JianCeResult = c.Boolean(nullable: false),
                        Description = c.String(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Materials", t => t.Material_Id, cascadeDelete: true)
                .Index(t => t.Material_Id);
            
            CreateTable(
                "dbo.JianCeItem",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        JianCe_Id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.JianCe", t => t.JianCe_Id, cascadeDelete: true)
                .Index(t => t.JianCe_Id);
            
            CreateTable(
                "dbo.JianCeTemplate",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Material_Id = c.Int(nullable: false),
                        Name = c.String(),
                        Description = c.String(),
                        FieldCategory = c.String(),
                        FField = c.String(),
                        FTable = c.String(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Materials", t => t.Material_Id, cascadeDelete: true)
                .Index(t => t.Material_Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.JianCeTemplate", "Material_Id", "dbo.Materials");
            DropForeignKey("dbo.JianCe", "Material_Id", "dbo.Materials");
            DropForeignKey("dbo.JianCeItem", "JianCe_Id", "dbo.JianCe");
            DropIndex("dbo.JianCeTemplate", new[] { "Material_Id" });
            DropIndex("dbo.JianCeItem", new[] { "JianCe_Id" });
            DropIndex("dbo.JianCe", new[] { "Material_Id" });
            DropTable("dbo.JianCeTemplate");
            DropTable("dbo.JianCeItem");
            DropTable("dbo.JianCe");
        }
    }
}
